<?php
class Engine_View_Helper_ImageUpload extends Zend_View_Helper_FormElement
{

	public function imageUpload($name, $value, $attribs, $options) {
		if(!empty($options[$name])) {
			$str = $this->getImagePreview($name, $options[$name]);
		} else {
			$str = $this->getEmptyPreview();
		}

		return $str;
	}

	private function getImagePreview($name, $path)
	{
		$img
			= ($this->view->doctype()->isXhtml())
			? '<img src="' . $path . '" alt="' . $name . '" />'
			: '<img src="' . $path . '" alt="' . $name . '">';

		return '<p class="preview">' . $img . '</p>';
	}

	private function getEmptyPreview()
	{
		return '<p class="preview">No image uploaded.</p>';
	}
}